from rest_framework import serializers

# serializers.ModelSerializer
from rest_framework.pagination import PageNumberPagination
from rest_framework.serializers import BaseSerializer, ModelSerializer

from testviewset.models import Book, User


# class MySer(BaseSerializer):
#
#     # class Meta:
#     #     model = Book
#         # fields
#
#     def to_representation(self, instance):
#         names = []
#         for ins in instance:
#             # print(type(instance))
#             names.append(ins.name)
#         # return instance.name
#         return names


class UserSer(ModelSerializer):

    class Meta:
        model = User
        fields = '__all__'


class UserPage(PageNumberPagination):
    page_size = 10  # default page size
    page_size_query_param = 'page_size'  # ?page=xx&size=??
    # 获取页码数的
    page_query_param = "page"
    # 最大页数不超过10
    max_page_size = 30
    # 测试修改内容，jenkins自动构建
    # 再次测试gitee
    # 测试修改内容，jenkins自动构建
    # 测试修改内容，jenkins自动构建
    # 测试修改内容，jenkins自动构建
    # 测试修改内容，jenkins自动构建